<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
用户名:<input id="username"/>
</body>
<script>
    //随机产生一个用户名
    //1:以大写的字母开头 后面四个小写的字母  在接四个数字
    var upperList = [];
    var lowerList = [];
    var numList = [];
    for (var i = 65; i < (65 + 26); i++) {//构建大写的集合
        var code = String.fromCharCode(i);
        upperList.push(code);
    }


    for (var i = 97; i < (97 + 26); i++) {//构建小写的集合
        var code = String.fromCharCode(i);
        lowerList.push(code);
    }

    for (var i = 0; i < 10; i++) {
        numList.push(String(i));
    }

    var str = upperList[Math.floor(Math.random() * (upperList.length))];

    for (var i = 0; i < 4; i++) {
        var rand = Math.round(Math.random() * (lowerList.length - 1));
        str += lowerList[rand];
    }

    for (var i = 0; i < 4; i++) {
        var rand = Math.round(Math.random() * (numList.length - 1));
        str += numList[rand];
    }
    var userInput = document.getElementById("username");
    userInput.value = str;
    //2:给你一份英文单词 把它全部转成大写   (Hello     HELLO)

</script>
</html>